package libs

import (
	"fmt"
	"github.com/jinzhu/gorm"
	_ "github.com/jinzhu/gorm/dialects/postgres"
)

func NewDBConn(config *Database) (*gorm.DB,   error){
	dsn := fmt.Sprintf("host=%s port=%d user=%s dbname=%s sslmode=disable password=%s",config.Host,config.Port,config.Username,config.DB,config.Password)
	db, err := gorm.Open("postgres", dsn)
	return db,err
}